-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refact: rust fixes and optimizations #933
refact: rust fixes and optimizations #933
Conversation
Use theme color instead of using ratatui::Color for running_command success and fail + search preview text color + min tui warning color, add colors for confirmation prompt, fix inverted success and fail colors
Removed redundant match statement with a function
Remove unnecessary usage of pub in ConfirmPropmt struct fields, simplify numbering, prevent scrolling beyond list, fix color bleeding
Use regex for case insesitive finding, implement String instead of char<Vec>, fix word disappearing by recalculating the render x for preview text
db0f6c5
to
0b4f33c
Compare
Other than the last point, why would we want to do any of these things? Compiling a regex on each change to the search input makes the code less readable & negatively impacts performance compared to just taking the lowercase of the input, which we already do.
Sorry, I misunderstood the changes made in that commit. It's even worse an idea than what I thought you were doing. If more themes are added, you'd have to keep adding function parameters, making the code even more difficult to read. A match statement is by far the best choice there. I oppose these 2 commits. I'll review certain elements of the other changes in a few minutes. |
tab completion was purposefully made to complete lowercase for UX & better visuals on the users end |
i personally think its better to keep it lowercase as it feels more snappier that way imo, tldr: makes the user think they have more control when searching |
This reverts commit 3b7e859.
Use Vec<char> for search_input to prevent panics when using multi-byte characters, use lowercase conversion instead of regex, Added comments for clarity
Thanks for the quick review. I forgot about the multi-byte characters reverted back to |
@cartercanedy @lj3954 Why we are using ansi colors for tree-sitter-highlighting instead of ratatui colors? |
Sorry, misunderstood the initial question Anstlye makes it easier to render the ansi color codes directly to a stream. There's some complication with using the ratatui text constructs since there might be some styling that needs to be applied over a line break, which would make parsing more complicated than necessary |
Since we using custom colors for syntax_highlighting_styles maybe using the ratatui colors reduces the complexity? What if ratatui colors is used and converted into lines using ratatui spans, lines or text instead of using anstyle and ansi_to_tui to convert them into text ? |
Trust me, it's just going to get more complicated... |
Ok I will try my best and create a commit let me know what you think about it |
Replaced ansi related code for tree sitter highlight with direct ratatui::text. Cache the processed text in appstate to remove processing of text for every frame render.Create paragraph instead of list so that scroll and wrapping can be done without external crates. Add caps keys for handle_key_event.
ae9d58b
to
10352c6
Compare
Is it normal for the checkout process to take in 10min in typos workflow 🙄 https://github.com/ChrisTitusTech/linutil/actions/runs/11782804516/job/32818643344?pr=933 |
The initial checkout can get throttled, I've seen that happen in my own projects |
Are the changes to the anstyle good ? Did you review the changes? |
Add labels + Wait 2sec after program ends
Skip Confirmation, Bypass Size
Revert handling find_command_name in state.rs Add options for skip_confirmation, size_bypass
4414f58
to
78b7c3f
Compare
Making the theme functions const doesn't accomplish anything useful; they'll still be evaluated at runtime since the theme is not known at compile time. |
We also should not be merging PRs like this. I find it unlikely Chris will accept anything with a 1500 line diff. |
It may not be now. But if we decide to change how themes work instead of passing the default theme at run time making it as default during compile time will make this more efficient. |
I'm aware of that. What can we do? Do I create 9 separate PRs for each commit? |
I don't mind the idea of marking methods const when compatible, |
Yes |
man that diff is HUGE |
I know we have put a lot of time into this. Separating the PRs will do the same. But this makes the program more efficient in many areas. Can't complain. |
fae67e3
to
fbbc295
Compare
fbbc295
to
3e888c3
Compare
Didn't expect you to actually merge this huge diff but ok. |
Thanks @lj3954 and @cartercanedy for your reviews and suggestions. Learnt a lot from you guys 😄
Type of Change
Notable changes so for
ratatui::Color
forrunning_command.rs
success and fail color +filter.rs
preview text color +state.rs
min-tui warning color,confirmation.rs
add colors for confirmation prompt,theme.rs
fix inverted success and fail colorsConfirmPrompt
struct fields toprivate
. Prevent scrolling beyond the list. Fix color bleeding.sort_unstable_by
no need ofsort_by
here, fix word disappearing by recalculating the render x for preview text.anstyle
andtext-wrap
withratatui
inbuilt functions. Prevent processing of text every frame by caching the processed text.- 6e5fe07 Adds back the removed clap features from cargo toml.fix: CLI arguments not working #935longest_tab_length
to appstate struct so that it will not be calculated for each frame rendered. Use function for spawning confirmprompt. Merge command list and task items list rendering a single widget instead of two. Remove redundant keys in handle_key.const
for theme functions.Testing
Before
After
Before
output.mp4
After
2024-11-10.21-38-15.mp4
Impact
Performance improvements and clean code base.
Issues / other PRs related
Checklist